package com.mobilelmes;

import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class CalFragment extends Fragment {

	private int fixedHeight = 40;
	private View view;
	public CalFragment() {
		// Empty constructor required for fragment subclasses
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View rootView = inflater.inflate(R.layout.fragment_calendar, container, false);
		view = rootView;
		try{
			AddMonItem(3,"Lang 2030",3,R.color.BlueViolet);
			AddMonItem(1,"Comp 3111 Tut",2,R.color.Aquamarine);
			AddMonItem(10,"Elec 4410 Lab",6,R.color.aqua);
			AddMonItem(18,"Comp 3711 Tut",2,R.color.android_green);
			
			AddTueItem(3,"Elec 4410",4,R.color.aqua);
			AddTueItem(9,"Comp 3021 Lab",2,R.color.blue);
			AddTueItem(12,"Comp 3111",3,R.color.Aquamarine);
			AddTueItem(15,"Comp 3021",3,R.color.blue);
			
			AddThurItem(3,"HUMA1102",3,R.color.LightSkyBlue);
		}
		catch(Exception ex){
			Log.d("Error - CalendarFragment", ex.getMessage());
		}
		return rootView;
	}
	public void AddMonItem(int PlaceFactor,String EventName,int Height,int Color){
		RelativeLayout Col = (RelativeLayout)view.findViewById(R.id.relativeLayout5);
		View v = new View(getActivity().getApplicationContext());
		v.setBackgroundResource(Color);
		v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,fixedHeight*Height));
		v.setY(fixedHeight*PlaceFactor);
		Button btn = new Button(getActivity().getApplicationContext());
		btn.setText(EventName);
		if(Height<3)
			btn.setTextSize(10);
		else
			btn.setTextSize(12);
		btn.setLayoutParams(new ViewGroup.LayoutParams(
	            ViewGroup.LayoutParams.MATCH_PARENT,
	           fixedHeight*Height));
		btn.setY(fixedHeight*PlaceFactor);
		Col.addView(v);
		Col.addView(btn);
	}
	public void AddTueItem(int PlaceFactor,String EventName,int Height,int Color){
		RelativeLayout Col = (RelativeLayout)view.findViewById(R.id.relativeLayout6);
		View v = new View(getActivity().getApplicationContext());
		v.setBackgroundResource(Color);
		v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,fixedHeight*Height));
		v.setY(fixedHeight*PlaceFactor);
		Button btn = new Button(getActivity().getApplicationContext());
		btn.setText(EventName);
		btn.setLayoutParams(new ViewGroup.LayoutParams(
	            ViewGroup.LayoutParams.MATCH_PARENT,
	            fixedHeight*Height));
		btn.setY(fixedHeight*PlaceFactor);
		Col.addView(v);
		Col.addView(btn);
	}
	public void AddWedItem(int PlaceFactor,String EventName,int Height,int Color){
		RelativeLayout Col = (RelativeLayout)view.findViewById(R.id.relativeLayout7);
		View v = new View(getActivity().getApplicationContext());
		v.setBackgroundResource(Color);
		v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,fixedHeight*Height));
		v.setY(fixedHeight*PlaceFactor);
		Button btn = new Button(getActivity().getApplicationContext());
		btn.setText(EventName);
		btn.setLayoutParams(new ViewGroup.LayoutParams(
	            ViewGroup.LayoutParams.MATCH_PARENT,
	            fixedHeight*Height));
		btn.setY(fixedHeight*PlaceFactor);
		Col.addView(v);
		Col.addView(btn);
	}
	public void AddThurItem(int PlaceFactor,String EventName,int Height,int Color){
		RelativeLayout Col = (RelativeLayout)view.findViewById(R.id.relativeLayout8);
		View v = new View(getActivity().getApplicationContext());
		v.setBackgroundResource(Color);
		v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,fixedHeight*Height));
		v.setY(fixedHeight*PlaceFactor);
		Button btn = new Button(getActivity().getApplicationContext());
		btn.setText(EventName);
		btn.setLayoutParams(new ViewGroup.LayoutParams(
	            ViewGroup.LayoutParams.MATCH_PARENT,
	            fixedHeight*Height));
		btn.setY(fixedHeight*PlaceFactor);
		Col.addView(v);
		Col.addView(btn);
	}
	public void AddFriItem(int PlaceFactor,String EventName,int Height,int Color){
		RelativeLayout Col = (RelativeLayout)view.findViewById(R.id.relativeLayout9);
		View v = new View(getActivity().getApplicationContext());
		v.setBackgroundResource(Color);
		v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,fixedHeight*Height));
		v.setY(fixedHeight*PlaceFactor);
		Button btn = new Button(getActivity().getApplicationContext());
		btn.setText(EventName);
		btn.setLayoutParams(new ViewGroup.LayoutParams(
	            ViewGroup.LayoutParams.MATCH_PARENT,
	            fixedHeight*Height));
		btn.setY(fixedHeight*PlaceFactor);
		Col.addView(v);
		Col.addView(btn);
	}
	public void AddSatItem(int PlaceFactor,String EventName,int Height,int Color){
		RelativeLayout Col = (RelativeLayout)view.findViewById(R.id.relativeLayout10);
		View v = new View(getActivity().getApplicationContext());
		v.setBackgroundResource(Color);
		v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,fixedHeight*Height));
		v.setY(fixedHeight*PlaceFactor);
		Button btn = new Button(getActivity().getApplicationContext());
		btn.setText(EventName);
		btn.setLayoutParams(new ViewGroup.LayoutParams(
	            ViewGroup.LayoutParams.MATCH_PARENT,
	            fixedHeight*Height));
		btn.setY(fixedHeight*PlaceFactor);
		Col.addView(v);
		Col.addView(btn);
	}
	public void AddSunItem(int PlaceFactor,String EventName,int Height,int Color){
		RelativeLayout Col = (RelativeLayout)view.findViewById(R.id.relativeLayout4);
		View v = new View(getActivity().getApplicationContext());
		v.setBackgroundResource(Color);
		v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,fixedHeight*Height));
		v.setY(fixedHeight*PlaceFactor);
		Button btn = new Button(getActivity().getApplicationContext());
		btn.setText(EventName);
		btn.setLayoutParams(new ViewGroup.LayoutParams(
	            ViewGroup.LayoutParams.MATCH_PARENT,
	            fixedHeight*Height));
		btn.setY(fixedHeight*PlaceFactor);
		Col.addView(v);
		Col.addView(btn);
	}
}
